package com.ibm.risk.irmp.workflow.client.flowable.api;

import com.ibm.risk.irmp.workflow.client.flowable.ApiClient;

import com.ibm.risk.irmp.workflow.client.flowable.model.DataResponseExecutionResponse;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionActionRequest;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionChangeActivityStateRequest;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionQueryRequest;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionResponse;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionVariableCollectionResource;
import com.ibm.risk.irmp.workflow.client.flowable.model.ExecutionVariableResource;
import java.io.File;
import com.ibm.risk.irmp.workflow.client.flowable.model.RestVariable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;


@Component("com.ibm.risk.irmp.flowable.api.ExecutionsApi")
public class ExecutionsApi {
    private ApiClient apiClient;

    public ExecutionsApi() {
        this(new ApiClient());
    }

    @Autowired
    public ExecutionsApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Change the state of an execution
     *
     * <p><b>200</b> - Indicates the execution was found and the action is performed.
     * <p><b>404</b> - Indicates the execution was not found.
     * @param executionId The executionId parameter
     * @param body The body parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void changeExecutionActivityState(String executionId, ExecutionChangeActivityStateRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling changeExecutionActivityState");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/change-state").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
        apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Create variables on an execution
     * This endpoint can be used in 2 ways: By passing a JSON Body (array of RestVariable) or by passing a multipart/form-data Object. Any number of variables can be passed into the request body array. NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.
     * <p><b>200</b> - successful operation
     * <p><b>201</b> - Indicates the execution was found and variable is created/updated.
     * <p><b>400</b> - Indicates the request body is incomplete or contains illegal values. The status description contains additional information about the error.
     * <p><b>404</b> - Indicates the requested execution was not found.
     * <p><b>409</b> - Indicates the execution was found but already contains a variable with the given name. Use the update-method instead.
     * @param executionId The executionId parameter
     * @param body Update a task variable
     * @param name Required name of the variable
     * @param type Type of variable that is updated. If omitted, reverts to raw JSON-value type (string, boolean, integer or double)
     * @param scope Scope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable..
     * @return Object
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public Object createExecutionVariable(String executionId, ExecutionVariableCollectionResource body, String name, String type, String scope) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling createExecutionVariable");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        if (name != null)
            formParams.add("name", name);
        if (type != null)
            formParams.add("type", type);
        if (scope != null)
            formParams.add("scope", scope);

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {
            "application/json", "multipart/form-data"
        };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Object> returnType = new ParameterizedTypeReference<Object>() {};
        return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Update variables on an execution
     * This endpoint can be used in 2 ways: By passing a JSON Body (array of RestVariable) or by passing a multipart/form-data Object. Any number of variables can be passed into the request body array. NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.
     * <p><b>200</b> - successful operation
     * <p><b>201</b> - Indicates the execution was found and variable is created/updated.
     * <p><b>400</b> - Indicates the request body is incomplete or contains illegal values. The status description contains additional information about the error.
     * <p><b>404</b> - Indicates the requested execution was not found.
     * @param executionId The executionId parameter
     * @param body Update a task variable
     * @param name Required name of the variable
     * @param type Type of variable that is updated. If omitted, reverts to raw JSON-value type (string, boolean, integer or double)
     * @param scope Scope of variable to be returned. When local, only task-local variable value is returned. When global, only variable value from the task’s parent execution-hierarchy are returned. When the parameter is omitted, a local variable will be returned if it exists, otherwise a global variable..
     * @return Object
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public Object createOrUpdateExecutionVariable(String executionId, ExecutionVariableCollectionResource body, String name, String type, String scope) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling createOrUpdateExecutionVariable");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        if (name != null)
            formParams.add("name", name);
        if (type != null)
            formParams.add("type", type);
        if (scope != null)
            formParams.add("scope", scope);

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {
            "application/json", "multipart/form-data"
        };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Object> returnType = new ParameterizedTypeReference<Object>() {};
        return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Delete all variables for an execution
     *
     * <p><b>204</b> - Indicates the execution was found and variables have been deleted.
     * <p><b>404</b> - Indicates the requested execution was not found.
     * @param executionId The executionId parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void deleteLocalVariables(String executionId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling deleteLocalVariables");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = { };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
        apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Delete a variable for an execution
     *
     * <p><b>204</b> - Indicates both the execution and variable were found and variable has been deleted.
     * <p><b>404</b> - Indicates the requested execution was not found or the execution does not have a variable with the given name in the requested scope. Status description contains additional information about the error.
     * @param executionId The executionId parameter
     * @param variableName The variableName parameter
     * @param scope The scope parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void deletedExecutionVariable(String executionId, String variableName, String scope) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling deletedExecutionVariable");
        }

        // verify the required parameter 'variableName' is set
        if (variableName == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'variableName' when calling deletedExecutionVariable");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        uriVariables.put("variableName", variableName);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables/{variableName}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "scope", scope));

        final String[] accepts = { };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
        apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Signal event received
     *
     * <p><b>204</b> - Indicates request was successful and the executions are returned
     * <p><b>404</b> - Indicates a parameter was passed in the wrong format . The status-message contains additional information.
     * @param body The body parameter
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public void executeExecutionAction(ExecutionActionRequest body) throws RestClientException {
        Object postBody = body;

        String path = UriComponentsBuilder.fromPath("/runtime/executions").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = { };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
        apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Get an execution
     *
     * <p><b>200</b> - Indicates the execution was found and returned.
     * <p><b>404</b> - Indicates the execution was not found.
     * @param executionId The executionId parameter
     * @return ExecutionResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ExecutionResponse getExecution(String executionId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling getExecution");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<ExecutionResponse> returnType = new ParameterizedTypeReference<ExecutionResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Get a variable for an execution
     *
     * <p><b>200</b> - Indicates both the execution and variable were found and variable is returned.
     * <p><b>400</b> - Indicates the request body is incomplete or contains illegal values. The status description contains additional information about the error.
     * <p><b>404</b> - Indicates the requested execution was not found or the execution does not have a variable with the given name in the requested scope (in case scope-query parameter was omitted, variable does not exist in local and global scope). Status description contains additional information about the error.
     * @param executionId The executionId parameter
     * @param variableName The variableName parameter
     * @param scope The scope parameter
     * @return RestVariable
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public RestVariable getExecutionVariable(String executionId, String variableName, String scope) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling getExecutionVariable");
        }

        // verify the required parameter 'variableName' is set
        if (variableName == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'variableName' when calling getExecutionVariable");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        uriVariables.put("variableName", variableName);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables/{variableName}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "scope", scope));

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<RestVariable> returnType = new ParameterizedTypeReference<RestVariable>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Get the binary data for an execution
     *
     * <p><b>200</b> - Indicates the execution was found and the requested variables are returned.
     * <p><b>404</b> - Indicates the requested execution was not found or the task does not have a variable with the given name (in the given scope). Status message provides additional information.
     * @param executionId The executionId parameter
     * @param variableName The variableName parameter
     * @param scope The scope parameter
     * @return List&lt;byte[]&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public List<byte[]> getExecutionVariableData(String executionId, String variableName, String scope) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling getExecutionVariableData");
        }

        // verify the required parameter 'variableName' is set
        if (variableName == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'variableName' when calling getExecutionVariableData");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        uriVariables.put("variableName", variableName);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables/{variableName}/data").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "scope", scope));

        final String[] accepts = { };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<List<byte[]>> returnType = new ParameterizedTypeReference<List<byte[]>>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * List active activities in an execution
     * Returns all activities which are active in the execution and in all child-executions (and their children, recursively), if any.
     * <p><b>200</b> - Indicates the execution was found and activities are returned.
     * <p><b>404</b> - Indicates the execution was not found.
     * @param executionId The executionId parameter
     * @return List&lt;String&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public List<String> listExecutionActiveActivities(String executionId) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling listExecutionActiveActivities");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/activities").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<List<String>> returnType = new ParameterizedTypeReference<List<String>>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * List variables for an execution
     *
     * <p><b>200</b> - Indicates the execution was found and variables are returned.
     * <p><b>404</b> - Indicates the requested execution was not found.
     * @param executionId The executionId parameter
     * @param scope The scope parameter
     * @return List&lt;RestVariable&gt;
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public List<RestVariable> listExecutionVariables(String executionId, String scope) throws RestClientException {
        Object postBody = null;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling listExecutionVariables");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "scope", scope));

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<List<RestVariable>> returnType = new ParameterizedTypeReference<List<RestVariable>>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * List of executions
     *
     * <p><b>200</b> - Indicates request was successful and the executions are returned
     * <p><b>400</b> - Indicates a parameter was passed in the wrong format . The status-message contains additional information.
     * @param id Only return models with the given version.
     * @param activityId Only return executions with the given activity id.
     * @param processDefinitionKey Only return process instances with the given process definition key.
     * @param processDefinitionId Only return process instances with the given process definition id.
     * @param processInstanceId Only return executions which are part of the process instance with the given id.
     * @param messageEventSubscriptionName Only return executions which are subscribed to a message with the given name.
     * @param signalEventSubscriptionName Only return executions which are subscribed to a signal with the given name.
     * @param parentId Only return executions which are a direct child of the given execution.
     * @param tenantId Only return process instances with the given tenantId.
     * @param tenantIdLike Only return process instances with a tenantId like the given value.
     * @param withoutTenantId If true, only returns process instances without a tenantId set. If false, the withoutTenantId parameter is ignored.
     * @param sort Property to sort on, to be used together with the order.
     * @return DataResponseExecutionResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public DataResponseExecutionResponse listExecutions(String id, String activityId, String processDefinitionKey, String processDefinitionId, String processInstanceId, String messageEventSubscriptionName, String signalEventSubscriptionName, String parentId, String tenantId, String tenantIdLike, Boolean withoutTenantId, String sort) throws RestClientException {
        Object postBody = null;

        String path = UriComponentsBuilder.fromPath("/runtime/executions").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "id", id));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "activityId", activityId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionKey", processDefinitionKey));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processDefinitionId", processDefinitionId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "processInstanceId", processInstanceId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "messageEventSubscriptionName", messageEventSubscriptionName));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "signalEventSubscriptionName", signalEventSubscriptionName));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "parentId", parentId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "tenantId", tenantId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "tenantIdLike", tenantIdLike));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "withoutTenantId", withoutTenantId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "sort", sort));

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<DataResponseExecutionResponse> returnType = new ParameterizedTypeReference<DataResponseExecutionResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Execute an action on an execution
     *
     * <p><b>200</b> - Indicates the execution was found and the action is performed.
     * <p><b>204</b> - Indicates the execution was found, the action was performed and the action caused the execution to end.
     * <p><b>400</b> - Indicates an illegal action was requested, required parameters are missing in the request body or illegal variables are passed in. Status description contains additional information about the error.
     * <p><b>404</b> - Indicates the execution was not found.
     * @param executionId The executionId parameter
     * @param body The body parameter
     * @return ExecutionResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public ExecutionResponse performExecutionAction(String executionId, ExecutionActionRequest body) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling performExecutionAction");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<ExecutionResponse> returnType = new ParameterizedTypeReference<ExecutionResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Query executions
     * The request body can contain all possible filters that can be used in the List executions URL query. On top of these, it’s possible to provide an array of variables and processInstanceVariables to include in the query, with their format described here.  The general paging and sorting query-parameters can be used for this URL.
     * <p><b>200</b> - Indicates request was successful and the executions are returned.
     * <p><b>404</b> - Indicates a parameter was passed in the wrong format . The status-message contains additional information.
     * @param body The body parameter
     * @return DataResponseExecutionResponse
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public DataResponseExecutionResponse queryExecutions(ExecutionQueryRequest body) throws RestClientException {
        Object postBody = body;

        String path = UriComponentsBuilder.fromPath("/query/executions").build().toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = { };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<DataResponseExecutionResponse> returnType = new ParameterizedTypeReference<DataResponseExecutionResponse>() {};
        return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
    /**
     * Update a variable on an execution
     * This endpoint can be used in 2 ways: By passing a JSON Body (RestVariable) or by passing a multipart/form-data Object. NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.
     * <p><b>200</b> - Indicates both the process instance and variable were found and variable is updated.
     * <p><b>404</b> - Indicates the requested process instance was not found or the process instance does not have a variable with the given name. Status description contains additional information about the error.
     * @param executionId The executionId parameter
     * @param variableName The variableName parameter
     * @param body Update a variable on an execution
     * @param file The file parameter
     * @param name The name parameter
     * @param type The type parameter
     * @param scope The scope parameter
     * @return RestVariable
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public RestVariable updateExecutionVariable(String executionId, String variableName, ExecutionVariableResource body, File file, String name, String type, String scope) throws RestClientException {
        Object postBody = body;

        // verify the required parameter 'executionId' is set
        if (executionId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'executionId' when calling updateExecutionVariable");
        }

        // verify the required parameter 'variableName' is set
        if (variableName == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'variableName' when calling updateExecutionVariable");
        }

        // create path and map variables
        final Map<String, Object> uriVariables = new HashMap<String, Object>();
        uriVariables.put("executionId", executionId);
        uriVariables.put("variableName", variableName);
        String path = UriComponentsBuilder.fromPath("/runtime/executions/{executionId}/variables/{variableName}").buildAndExpand(uriVariables).toUriString();

        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

        if (file != null)
            formParams.add("file", new FileSystemResource(file));
        if (name != null)
            formParams.add("name", name);
        if (type != null)
            formParams.add("type", type);
        if (scope != null)
            formParams.add("scope", scope);

        final String[] accepts = {
            "application/json"
        };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {
            "application/json", "multipart/form-data"
        };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] { "basicAuth" };

        ParameterizedTypeReference<RestVariable> returnType = new ParameterizedTypeReference<RestVariable>() {};
        return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
}
